{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f04dd603-a2d1-48ce-8c17-9f1dba8de1ee",
   "metadata": {},
   "source": [
    "Chapter 08\n",
    "\n",
    "# 平面缩放\n",
    "《线性代数》 | 鸢尾花书：数学不难"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccafb456-2453-4c82-8a65-b1963a370cb2",
   "metadata": {},
   "source": [
    "这段代码从数学角度展示了线性变换如何作用于单位正方形以及标准基向量 $\\mathbf{e}_1 = \\begin{bmatrix}1 \\\\ 0\\end{bmatrix}$ 与 $\\mathbf{e}_2 = \\begin{bmatrix}0 \\\\ 1\\end{bmatrix}$，并以图形方式呈现其变换后的结果。\n",
    "\n",
    "---\n",
    "\n",
    "### 线性变换矩阵\n",
    "\n",
    "我们设定了一个二维线性变换矩阵 $A$，定义如下：\n",
    "$$\n",
    "A = \\begin{bmatrix}\n",
    "2 & 0 \\\\\n",
    "0 & 2\n",
    "\\end{bmatrix}\n",
    "$$\n",
    "该矩阵是一个**各向同性缩放矩阵（isotropic scaling matrix）**，它会将所有向量的长度放大为原来的两倍，且保持方向不变。\n",
    "\n",
    "---\n",
    "\n",
    "### 单位正方形的顶点与其变换\n",
    "\n",
    "接下来定义单位正方形的五个顶点，依次是左下角、右下角、右上角、左上角，并最后闭合回左下角。这些点构成一个边长为 1 的正方形，其矩阵表示为：\n",
    "$$\n",
    "\\text{square} =\n",
    "\\begin{bmatrix}\n",
    "0 & 0 \\\\\n",
    "1 & 0 \\\\\n",
    "1 & 1 \\\\\n",
    "0 & 1 \\\\\n",
    "0 & 0\n",
    "\\end{bmatrix}\n",
    "$$\n",
    "\n",
    "由于我们需要对这些二维坐标进行线性变换，因此通过右乘 $A^\\top$ 实现：\n",
    "$$\n",
    "\\text{transformed\\_square} = \\text{square} \\cdot A^\\top\n",
    "$$\n",
    "这是因为 NumPy 默认每一行是一个二维向量（即点），所以右乘转置矩阵 $A^\\top$ 等价于标准左乘$A$：\n",
    "$$\n",
    "\\text{square}[i] \\mapsto A \\cdot \\text{square}[i]^\\top\n",
    "$$\n",
    "\n",
    "在当前例子中，由于 $A$ 是对称矩阵，有 $A^\\top = A$，故此转置不会改变运算结果。\n",
    "\n",
    "变换的几何含义是：单位正方形被整体缩放，新的顶点变为原来的两倍距离，即每个点 $\\mathbf{p}$ 被映射为 $A \\cdot \\mathbf{p}$。\n",
    "\n",
    "---\n",
    "\n",
    "### 单位向量的变换\n",
    "\n",
    "单位向量定义为：\n",
    "$$\n",
    "\\mathbf{e}_1 = \\begin{bmatrix}1 \\\\ 0\\end{bmatrix}, \\quad \\mathbf{e}_2 = \\begin{bmatrix}0 \\\\ 1\\end{bmatrix}\n",
    "$$\n",
    "它们分别表示二维坐标轴的 x 和 y 方向。在变换 $A$ 下，它们分别变为：\n",
    "$$\n",
    "A \\cdot \\mathbf{e}_1 = \\begin{bmatrix}2 \\\\ 0\\end{bmatrix}, \\quad\n",
    "A \\cdot \\mathbf{e}_2 = \\begin{bmatrix}0 \\\\ 2\\end{bmatrix}\n",
    "$$\n",
    "这意味着原本单位长度的基向量被放大为长度为 2，方向不变。\n",
    "\n",
    "---\n",
    "\n",
    "### 图像可视化与解释\n",
    "\n",
    "绘图部分使用 `matplotlib` 来展示变换前后的形状：\n",
    "\n",
    "- 使用虚线 `k--` 绘制原始单位正方形。\n",
    "- 使用实线 `k-` 和 `fill()` 填充变换后的正方形，表现其新形状。\n",
    "- 使用 `quiver()` 绘制变换后的 $\\mathbf{e}_1$ 和 $\\mathbf{e}_2$，颜色分别为绿色和黑色，起点均为原点 $(0,0)$。\n",
    "- 添加 x 轴与 y 轴参考线，保持图形长宽比例一致，设定坐标范围和网格，增强图像清晰度。\n",
    "\n",
    "---\n",
    "\n",
    "### 总结\n",
    "\n",
    "该程序通过如下数学过程展示线性变换的几何效果：\n",
    "\n",
    "- $$\\mathbf{v} \\mapsto A \\cdot \\mathbf{v}$$，对单位正方形顶点和单位向量进行仿射变换；\n",
    "- 当 $A$ 是一个缩放矩阵时，图形大小按比例放大或缩小；\n",
    "- 变换保持图形形状为平行四边形（对于一般线性变换），或矩形（对于对角矩阵），并改变大小、方向或角度。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2206ef94-af72-4df1-b0a9-3f4439c8032b",
   "metadata": {},
   "source": [
    "## 初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "26f02fdb-b342-4403-a0d8-28b041f064ac",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0cddbdb-da4f-4ddc-993f-6903e6d3bd35",
   "metadata": {},
   "source": [
    "## 线性变换矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "b6e368a0-4d3c-4631-b7d4-638e6887fd07",
   "metadata": {},
   "outputs": [],
   "source": [
    "A = np.array([[2, 0],\n",
    "              [0, 1/2]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddce0db0-353a-4007-b5c6-f2659b969374",
   "metadata": {},
   "source": [
    "## 单位正方形顶点数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ab139c32-0282-40d5-987c-a337cf88697c",
   "metadata": {},
   "outputs": [],
   "source": [
    "square_data = np.array([[0, 0],\n",
    "                        [1, 0],\n",
    "                        [1, 1],\n",
    "                        [0, 1],\n",
    "                        [0, 0]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fac7293a-8596-439d-921e-7d34688bdd02",
   "metadata": {},
   "source": [
    "## 定义单位向量 e1 和 e2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "24680a21-6ebe-4922-aabf-e51482d5c60b",
   "metadata": {},
   "outputs": [],
   "source": [
    "e1 = np.array([[1], \n",
    "               [0]]) \n",
    "\n",
    "e2 = np.array([[0], \n",
    "               [1]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84dd4a58-2025-4cb0-9a9f-24e65bfc5554",
   "metadata": {},
   "source": [
    "## 线性变换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c0c541bc-502d-4e1b-8c13-a11e12ef6024",
   "metadata": {},
   "outputs": [],
   "source": [
    "transformed_square = square_data @ A.T \n",
    "transformed_e1 = A @ e1\n",
    "transformed_e2 = A @ e2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b8fd3a0-d41a-40c8-ab67-a8f569564d3e",
   "metadata": {},
   "source": [
    "## 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cef259c0-c755-4cdc-98fe-813795facbc4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAH/CAYAAAAov8XRAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAjPUlEQVR4nO3df5TU9X33/de6yoriLiCKWhZBOTWK+COgEe6gS0QqsQbkYPU0tSaxPdGgR2Obxh+pQJuEWDXWkxhrLnPQ676Nv1eJGqmYukCuiGJuuUW8tJdEuiIqEmAR6lnqOPcfhBWE1R3ozOzq43HOnDPznZn9vv04wzz5zrBTUywWiwEAPtX2qPYAAED1CQIAQBAAAIIAAIggAAAiCACACAIAIIIAAIggAAAiCACAlDkIbrnllhxzzDGpr69PfX19Ro8enccee6ycuwQAdkFNOb/L4OGHH05tbW2GDRuWJLnjjjty3XXX5bnnnsvw4cPLtVsAoERlDYKd6d+/f6677rpccMEFldwtAPAR9qzUjgqFQu67775s2rQpo0eP3ult2tvb097e3nH5/fffz9q1a7P//vunpqamUqMCQI9ULBbzzjvv5JBDDskee5T4qYBimT3//PPFfffdt1hbW1tsaGgoPvroo53edvr06cUkTk5OTk5OTrtxeu2110p+vS77WwabN29Oa2tr1q9fnwceeCC33XZb5s+fn6OOOmqH2374CEFbW1sGDx6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0t7d3XN6wYUMaGxvLMR4AfGLtShCU7S2DNWvWpFAoZODAgdttHzhwYN58882d3mfWrFlpaGjoOIkBAKiMPcu9g5qamu0uF4vFHbZtdeWVV27373S3HiFYsWKFtwy6qFAoZNmyZRk+fLhDbF1kzT7eueeem8cee2zLZwb6DU/+nz+E/l+8ley1b7L66eTRU3Pan0zMbf/z/67obE/9r/+Vc6dM2jLbgSfueIM/zPbwww/n5JNPrthcCxYsyJlnntnt5upJPDdLt27dugwZMmSX7lu2IBgwYEBqa2t3OBqwevXqHY4abFVXV5e6urodttfX15d86OPTqlAopHfv3qmvr/cE6iJr9vHuvffe7FffL1n6w+QLP//gir323fIZgqU3JjV7pvn+e9OnT2U/Q/BHXzojgwYPyesv3JjihId2eK++5oV/zqBDh2bixIkV/f87ceLEbjlXT+K5Wbrd+SetZXvLoFevXhk5cmTmzZu33fZ58+ZlzJgx5dotUAZ9+vTJCaOOT1of2fIBwq1WP53866Sk9ZGcMOr4isdAktTW1uamG29IWh9JzeOTk7eeSja/k7z11JbLrY/kn394fcVfULrrXNCpYhndfffdxb322qv4s5/9rPjiiy8WL7vssuK+++5bXLFiRZfu39bWVkxSXLt2bTnH/ER57733is8++2zxvffeq/YoPYY167oTTjihmNQWk3xwqtmzeMIJJ1R7tOIDDzxQHDR4yHazNR46tPjAAw+Yq4fy3Czd2rVri0mKbW1tJd+3rJ8hOOecc/L73/8+//AP/5A33ngjRx99dH75y1/m0EMPLedugTJ55pln8tZbb+Wggw5KsuWw+L33Vv5tgp2ZMmVKJk2alIULF+aNN97IwQcfnLFjx1b9b+Bb52ppacmiRYty0kknpampqepzwYeV/UOF3/jGN/KNb3yj3LsBKmTbF/+77767W8TAVrW1tWlqaqr2GDvYOlffvn1z3HHHiQG6Jd9lAAAIAgBAEAAAEQQAQAQBABBBAABEEAAAEQQAQAQBABBBAABEEAAAEQQAQAQBABBBAABEEAAAEQQAQAQBABBBAABEEAAAEQQAQAQBABBBAABEEAAAEQQAQAQBABBBAABEEA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k6dGh69+6dww8/PNOnT8/mzZvLtUsAYBftWa4f/NJLL+X999/PrbfemmHDhuWFF17IX//1X2fTpk25/vrry7VbAGAXlC0ITj/99Jx++ukdlw877LC8/PLLueWWWwQBAHQzZQuCnWlra0v//v07vb69vT3t7e0dlzds2JAkKRQKKRQKZZ/vk2DrOlmvrrNmpdl2nTw3u87jrHTWrHS7s1YVC4Lly5fnRz/6UW644YZObzNr1qzMnDlzh+3Lli1Lnz59yjneJ87SpUurPUKPY8265t133+04v2zZsvTu3buK0/Q8Hmels2Zdt3Hjxl2+b02xWCyWcocZM2bs9EV7W4sXL86oUaM6Lq9atSqnnHJKTjnllNx2222d3m9nRwgaGxvz9ttvp1+/fqWM+alVKBSydOnSjBgxIrW1tdUep0ewZqXZtGlTGhoakiRr165NfX19lSfqGTzOSmfNSrdu3boccMABaWtrK/m5WfIRgosvvjjnnnvuR95myJAhHedXrVqVcePGZfTo0fnpT3/6kferq6tLXV3dDttra2s9GEpkzUpnzbpm2zWyZqWzZqWzZl23O+tUchAMGDAgAwYM6NJtX3/99YwbNy4jR47M7Nmzs8cefu0BAHRHZfsMwapVq9LU1JTBgwfn+uuvz9tvv91x3UEHHVSu3QIAu6BsQfD444/nlVdeySuvvJJBgwZtd12JH1sAAMqsbMfwv/KVr6RYLO70BAB0L97UBwAEAQAgCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAIggAABS5iD40pe+lMGDB2fvvffOwQcfnPPOOy+rVq0q5y4BgF1Q1iAYN25c7r333rz88st54IEHsnz58kydOrWcu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mnSpCxbtqzrP2SXvrGoG5gzZ06xpqamuHnz5mqP0mP80z/9U3Ho0KHVHqNHmD17drGhoaHaY3RLJ554YvHCCy/cbttnPvOZ4hVXXFGliXqOJMUHH3yw2mP0OKtXry4mKc6fP7/ao/Qo/fr1K952221dvn2POUKwra58lTI7amtrS//+/as9Bj3Y5s2b89vf/jYTJkzYbvuECRPym9/8pkpT8UnX1taWJP786qJCoZC77747mzZtKuk3A/eoIPj2t7+dfffdN/vvv39aW1szZ86cao/UYyxfvjw/+tGPcuGFF1Z7FHqwNWvWpFAoZODAgdttHzhwYN58880qTcUnWbFYzOWXX57Pf/7zOfroo6s9Tre2dOnS9OnTJ3V1dbnwwgvz4IMP5qijjury/asaBDNmzEhNTc1Hnp599tmO23/rW9/Kc889l8cffzy1tbX5y7/8y44vTPq0KHXNkmTVqlU5/fTTc/bZZ+ev/uqvqjR59ezKmvHRPvz15cVicadfaQ676+KLL87zzz+fu+66q9qjdHtHHHFElixZkkWLFuWiiy7K+eefnxdffLHL9y/blxt1xcUXX5xzzz33I28zZMiQjvNbv2nxj//4j3PkkUemsbExixYt+lR9WVKpa7Zq1aqMGzcuo0ePzk9/+tMyT9c9lbpmdG7AgAGpra3d4WjA6tWrdzhqALvrkksuyS9+8YssWLAggwYNqvY43V6vXr0ybNiwJMmoUaOyePHi3HTTTbn11lu7dP+qBoGvUi5dKWv2+uuvZ9y4cRk5cmRmz56dPfboUe8Q/bfZnccZ2+vVq1dGjhyZefPm5ayzzurYPm/evEyaNKmKk/FJUiwWc8kll+TBBx9MS0tLhg4dWu2ReqRisVjSa2RVg6CrfJVy6VatWpWmpqYMHjw4119/fd5+++2O6w466KAqTta9tba2Zu3atWltbU2hUMiSJUuSJMOGDUufPn2qO1w3cfnll+e8887LqFGjOo48tba2+nxKJzZu3JhXXnml4/Krr76aJUuWpH///hk8eHAVJ+u+pk2blp///OeZM2dO9ttvv44jUg0NDendu3eVp+uerrrqqkycODGNjY155513cvfdd6elpSVz587t+g8py791+G/2/PPPF8eNG1fs379/sa6urjhkyJDihRdeWFy5cmW1R+u2Zs+eXUyy0xOdO//883e6Zk8++WS1R+tWbr755uKhhx5a7NWrV/Gzn/2sfw72EZ588smdPqbOP//8ao/WbXX2Z9fs2bOrPVq39bWvfa3jOXnAAQcUTz311OLjjz9e0s/w9ccAQM/6Z4cAQHkIAgBAEAAAggAAiCAAACIIAIAIAgAgggAAiCAAACIIAIAIAgAgggAASPL/A9jFgrRIGxROAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 600x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = plt.subplots(figsize=(6, 6))\n",
    "\n",
    "ax.plot(square_data[:,0], square_data[:,1], c = 'k', lw = '0.5',\n",
    "        marker = 'o', markerfacecolor = '#0066FF', ls = '--')\n",
    "ax.plot(transformed_square[:,0], transformed_square[:,1], c = 'k', lw = '0.5',\n",
    "        marker = 'o', markerfacecolor = '#0066FF', ls = '-')\n",
    "ax.fill(transformed_square[:,0], transformed_square[:,1], color='lightblue')\n",
    "\n",
    "ax.set_aspect('equal')\n",
    "ax.axhline(y = 0, c = 'k')\n",
    "ax.axvline(x = 0, c = 'k')\n",
    "ax.set_xlim(-3, 3)\n",
    "ax.set_ylim(-3, 3)\n",
    "ax.grid(True, c = '0.8')\n",
    "plt.savefig('1.svg')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "954b7525-dcef-47cb-af13-40c741ca3891",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "070c3389-8048-43a3-baa7-6666009bce96",
   "metadata": {},
   "source": [
    "作者\t**生姜DrGinger**  \n",
    "脚本\t**生姜DrGinger**  \n",
    "视频\t**崔崔CuiCui**  \n",
    "开源资源\t[**GitHub**](https://github.com/Visualize-ML)  \n",
    "平台\t[**油管**](https://www.youtube.com/@DrGinger_Jiang)\t\t\n",
    "\t\t[**iris小课堂**](https://space.bilibili.com/3546865719052873)\t\t\n",
    "\t\t[**生姜DrGinger**](https://space.bilibili.com/513194466)  "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
